﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/ResponsiveTheme.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TaggerApp.Admin.Pages.Locations.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style>  body {padding-top: 60px;padding-bottom: 40px;}      </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
            <div class="text-right">
                <input id="btnAddNewLocation" type="button" value="Add New Location" class="btn btn-success " onclick="location.href='<%=ResolveClientUrl("../AddLocations/") %>'" />
            </div>   
  
    <hr/>
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" AppendDataBoundItems="True" DataSourceID="SqlDSDropDown" DataTextField="State" DataValueField="State">
                 <asp:listitem value="%" Selected="True">All</asp:listitem>
    </asp:DropDownList>
    
            <asp:SqlDataSource ID="SqlDSDropDown" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT DISTINCT [State] FROM [tblLocation]"></asp:SqlDataSource>
    
     <asp:GridView ID="gvLocations" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="locationID" DataSourceID="SqlDSLocations" CssClass="table table-bordered table-hover">
        <Columns>
            <asp:BoundField DataField="locationID" HeaderText="locationID" SortExpression="locationID" ItemStyle-CssClass="hidecol" HeaderStyle-CssClass="hidecol">
<HeaderStyle CssClass="hidecol"></HeaderStyle>

<ItemStyle CssClass="hidecol"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="locationName" HeaderText="Location Name" SortExpression="locationName"  />
            <asp:BoundField DataField="locationPlace" HeaderText="Location Place" SortExpression="locationPlace" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" ItemStyle-CssClass="hidecol" HeaderStyle-CssClass="hidecol">
<HeaderStyle CssClass="hidecol"></HeaderStyle>

<ItemStyle CssClass="hidecol"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="Address2" HeaderText="Address 2" SortExpression="Address2" ItemStyle-CssClass="hidecol" HeaderStyle-CssClass="hidecol">
<HeaderStyle CssClass="hidecol"></HeaderStyle>

<ItemStyle CssClass="hidecol"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
            <asp:BoundField DataField="ZipCode" HeaderText="Zip Code" SortExpression="ZipCode" ItemStyle-CssClass="hidecol" HeaderStyle-CssClass="hidecol">
<HeaderStyle CssClass="hidecol"></HeaderStyle>

<ItemStyle CssClass="hidecol"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
            <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
            <asp:BoundField DataField="Province" HeaderText="Province" SortExpression="Province" ItemStyle-CssClass="hidecol" HeaderStyle-CssClass="hidecol">
<HeaderStyle CssClass="hidecol"></HeaderStyle>

<ItemStyle CssClass="hidecol"></ItemStyle>
            </asp:BoundField>

            <asp:HyperLinkField DataNavigateUrlFormatString="../EditLocationInfo/Default.aspx?id={0}" DataNavigateUrlFields="locationID" Text="View / Edit" ControlStyle-CssClass="btn btn-primary" >
<ControlStyle CssClass="btn btn-primary"></ControlStyle>
            </asp:HyperLinkField>


            <asp:CommandField ShowDeleteButton="True" ControlStyle-CssClass="btn btn-danger">
<ControlStyle CssClass="btn btn-danger"></ControlStyle>
            </asp:CommandField>
        </Columns>
    </asp:GridView>
    
    <asp:SqlDataSource ID="SqlDSLocations" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [tblLocation] WHERE [locationID] = @locationID" InsertCommand="INSERT INTO [tblLocation] ([locationName], [locationPlace], [Address], [Address2], [City], [ZipCode], [State], [Country], [Province]) VALUES (@locationName, @locationPlace, @Address, @Address2, @City, @ZipCode, @State, @Country, @Province)" SelectCommand="SELECT * FROM [tblLocation]" FilterExpression="[State] like '{0}%'" UpdateCommand="UPDATE [tblLocation] SET [locationName] = @locationName, [locationPlace] = @locationPlace, [Address] = @Address, [Address2] = @Address2, [City] = @City, [ZipCode] = @ZipCode, [State] = @State, [Country] = @Country, [Province] = @Province WHERE [locationID] = @locationID">
        <DeleteParameters>
            <asp:Parameter Name="locationID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="locationName" Type="String" />
            <asp:Parameter Name="locationPlace" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="Address2" Type="String" />
            <asp:Parameter Name="City" Type="String" />
            <asp:Parameter Name="ZipCode" Type="Int32" />
            <asp:Parameter Name="State" Type="String" />
            <asp:Parameter Name="Country" Type="String" />
            <asp:Parameter Name="Province" Type="String" />
        </InsertParameters>
        <FilterParameters>
            <asp:ControlParameter ControlID="DropDownList1" Name="State" PropertyName="SelectedValue" Type="String" />
        </FilterParameters>
        <UpdateParameters>
            <asp:Parameter Name="locationName" Type="String" />
            <asp:Parameter Name="locationPlace" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="Address2" Type="String" />
            <asp:Parameter Name="City" Type="String" />
            <asp:Parameter Name="ZipCode" Type="Int32" />
            <asp:Parameter Name="State" Type="String" />
            <asp:Parameter Name="Country" Type="String" />
            <asp:Parameter Name="Province" Type="String" />
            <asp:Parameter Name="locationID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>